package com.toune.villager.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.toune.dltools.http.GsonBinder;
import com.toune.villager.R;
import com.toune.villager.bean.MyInfoBean;

import java.math.RoundingMode;
import java.util.List;

public class AdapterMyInfoList extends BaseMultiItemQuickAdapter<MyInfoBean.DataBean, BaseViewHolder> implements LoadMoreModule {
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public AdapterMyInfoList(List data) {
        super(data);
        addItemType(MyInfoBean.DataBean.TYPE1, R.layout.layout_msg_type1);
        addItemType(MyInfoBean.DataBean.TYPE2, R.layout.layout_msg_type2);
    }


    @Override
    protected void convert(BaseViewHolder helper, MyInfoBean.DataBean item) {
        switch (helper.getItemViewType()) {
            case MyInfoBean.DataBean.TYPE1:
//                MessageType1Vo messageType1Vo = GsonBinder.toObj(item.getContent(), MessageType1Vo.class);
//                if (messageType1Vo != null) {
//                    helper.setGone(R.id.plate_num_tv, true);
//                    helper.setText(R.id.plate_num_tv, "【" + messageType1Vo.getPlate_number() + "】");
//                    helper.setText(R.id.fac_name_tv, messageType1Vo.getFactory_name());
//                    helper.setText(R.id.stone_name_tv, messageType1Vo.getStone_name());
//                    helper.setText(R.id.stone_num_tv, messageType1Vo.getNum() + "吨");
//                    String price = CalcUtils.multiply(Double.parseDouble(messageType1Vo.getPrice()), Double.parseDouble(messageType1Vo.getNum() + ""), 2, RoundingMode.CEILING) + "";
//                    helper.setText(R.id.price_tv, price);
//                } else {
//                    helper.setGone(R.id.plate_num_tv, false);
//                }
//                helper.setText(R.id.push_time_tv, item.getPush_time());
                break;
            case MyInfoBean.DataBean.TYPE2:
            default:
                ImageView imageView = helper.getView(R.id.msg_iv);
                helper.setText(R.id.title_tv, item.getTitle());
                helper.setText(R.id.push_time_tv, item.getPush_time());
                break;
        }
    }

    class MessageType1Vo {
        float num;
        String factory_name;
        String stone_name;
        String plate_number;
        String price;

        public float getNum() {
            return num;
        }

        public void setNum(float num) {
            this.num = num;
        }

        public String getFactory_name() {
            return factory_name;
        }

        public void setFactory_name(String factory_name) {
            this.factory_name = factory_name;
        }

        public String getStone_name() {
            return stone_name;
        }

        public void setStone_name(String stone_name) {
            this.stone_name = stone_name;
        }

        public String getPlate_number() {
            return plate_number;
        }

        public void setPlate_number(String plate_number) {
            this.plate_number = plate_number;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }
    }
}
